package com.tanhua.dubbo.api.impl;

import com.tanhua.domain.mongo.SoulReport;
import com.tanhua.dubbo.api.SoulReportApi;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

@Service
public class SoulReportApiImpl implements SoulReportApi {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public SoulReport findReportByType(String type) {

        Query query = new Query(Criteria.where("type").is(type));
        return mongoTemplate.findOne(query, SoulReport.class);
    }

    @Override
    public SoulReport findReportById(String reportId) {

        return mongoTemplate.findById(reportId, SoulReport.class);

    }

}
